/**
 * @param {string} s
 * @return {number}
 */
var lengthOfLastWord = function (s) {
  const list = s.split(" ");

  let result = null;

  for (let i = list.length - 1; i >= 0; i--) {
    if (result === null && list[i].length > 0) {
      result = list[i].length;
    }
  }

  return result;
};
